﻿using Se.Model.Achievement.AchItem;
using Se.Model.Template;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using P1004.TexasHoldemLib;
namespace Se.Model.Achievement
{
    public class AchievementConditionFactory
    {
        /// <summary>
        /// 创建成就达成项
        /// </summary>
        /// <param name="ach"></param>
        /// <returns></returns>
        public static AchievementConditionBase CreateAchievementCondition(long playerId, AchievementTemplate ach, int currentCount = 0)
        {
            var condition = CreateAchievementCondition(playerId, ach.Type, ach.Count, ach.Param1, ach.Param2, currentCount);
            return condition;
        }

        /// <summary>
        /// 创建达成项
        /// </summary>
        /// <param name="type"></param>
        /// <param name="count"></param>
        /// <param name="param1"></param>
        /// <param name="param2"></param>
        /// <param name="currentCount"></param>
        /// <returns></returns>
        private static AchievementConditionBase CreateAchievementCondition(long playerId, int type, int count, string param1, string param2, int currentCount = 0)
        {
            AchievementConditionBase ach = null;
            var conditionType = (AchievementConditionEnum)type;
            switch (conditionType)
            {
                //自动完成
                case AchievementConditionEnum.ClientNotice:
                case AchievementConditionEnum.DailyPrize:
                    ach = new AchievementAutoComplete(conditionType);
                    break;
                default:
                    Se.Log.SeLog.Error("错误的成就项:type {0}", type);
                    break;
            }
            if (ach != null)
            {
                ach.Init(count, currentCount, param1, param2);
                ach.PlayerId = playerId;
            }
            return ach;
        }
    }
}
